Page({
  // 作用是点击更多后，如果点击页面的空白部分，则关闭popover
  clearSelectedId() {
    this.setData({
      selectid: null
    })
  },
  data: {
    userOrderList: [{
      list: [{
        _id: "1",
        vo: {
          _id: "8u8u8"
        }
      }]
    }, {
      list: [{
        _id: "2",
        vo: {
          _id: "18u8u8"
        }
      }]
    }, {
      list: [{
        _id: "8",
        vo: {
          _id: "18u8u38"
        }
      }]
    }, {
      list: [{
        _id: "3",
        vo: {
          _id: "18u82u8"
        }
      }]
    }, {
      list: [{
        _id: "4",
        vo: {
          _id: "18u81u8"
        }
      }]
    }],
    money: 0, //订单金额

    // 这部分应该每一个订单的操作都有差别，应该做成动态的
    // 思路：根据订单状态码给订单item添加动态列表，将动态数据作为item的一部分
    moreText: [{
      id: 0,
      name: '修改订单'
    }, {
      id: 1,
      name: '取消订单'
    }, {
      id: 2,
      name: '服务评价'
    }, {
      id: 3,
      name: '开发票'
    }],
    orderid: '',
    selectid: 0
  },
  /**
   * 点击下拉框
   */
  bindShowMsg(e) {
    let that = this
    let id = e.currentTarget.dataset.id;
    console.log('id', id)

    if (!this.data.selectid) { //判断是否已经点击更多
      that.setData({  //显示更多
        selectid: id
      })
    } else {
      that.setData({ //隐藏更多
        selectid: 0
      })
    }
  },
  /**
    * 已选下拉框
    */
  mySelect(e) {
    let that = this
    let name = e.currentTarget.dataset.name
    let id = e.currentTarget.dataset.id;
    let status = e.currentTarget.dataset.status
    let isEvaluate = e.currentTarget.dataset.isEvaluate
    console.log('id', id)
    console.log('name', name)
    console.log('status', status)
    console.log('isEvaluate', isEvaluate)

    if (name == '修改订单') {
      that.modifyDetails(id)
      that.setData({
        selectid: 0
      })
    } else if (name == '取消订单' && status == 0) {
      that.cancelOrder(id)
      that.setData({
        selectid: 0
      })
    } else if (name == '服务评价') {
      if (status == 2 && isEvaluate == 0) {
        that.evaluation(id)
        that.setData({
          selectid: 0
        })
      } else {
        return wx.showModal({
          title: '温馨提示',
          content: '当前功能暂未开放',
          showCancel: false,
          success(res) {
            if (res.confirm) {
              console.log('用户点击确定')
              that.setData({
                selectid: 0
              })
            }
          }
        })
      }
    } else if (name == '开发票') {
      if (status == 2) {
        that.makeInvoice(id)
        that.setData({
          selectid: 0
        })
      } else {
        return wx.showModal({
          title: '温馨提示',
          content: '当前功能暂未开放',
          showCancel: false,
          success(res) {
            if (res.confirm) {
              console.log('用户点击确定')
              that.setData({
                selectid: 0
              })
            }
          }
        })
      }
    }
  },
})